<template>
    <div class="newsinfo-container">
        <h3 class="title">{{data[0].title}}</h3>
        <div class="sectitle">
            <span>发表时间：{{data[0].add_time | dateFormat}}</span>
            <span>点击：{{data[0].click}}</span>
        </div>
        <hr>
        <div class="content" v-html="data[0].content"></div>
        <comments :id="id"></comments>
    </div>
</template>

<script>
    import {
        toast
    } from 'mint-ui';
    import comments from '../subcomponents/comment.vue';
    export default {
        data() {
            return {
                id: this.$route.params.id,
                data: []
            }
        },
        methods: {
            getData() {
                this.$http.get('api/getnew/' + this.id).then(res => {
                    if (res.body.status == 0) {
                        this.data = res.body.message;
                        console.log(this.data);
                    } else {
                        toast('获取数据失败');
                    }
                })
            }
        },
        created() {
            this.getData();
        },
        components: {
            comments: comments,
        }
    }
</script>

<style lang="less">
    .newsinfo-container {
        padding: 0 4px;
        .title {
            font-size: 16px;
            color: #3c3c3c;
            text-align: center;
            padding: 15px 0;
        }
        .sectitle{
            font-size: 12px;
            color: skyblue;
            display: flex;
            justify-content: space-between;
        }
        .content img {
            width: 100%;
        }
    }
</style>